#include "Delete_Operation.h"


Delete_Operation::Delete_Operation(void)
{
}

Delete_Operation::Delete_Operation(char *dn):LDAP_Operation(dn)
{
}

Delete_Operation::Delete_Operation(char *dn,vector<Atribut<char*>> atribute):LDAP_Operation(dn,atribute)
{
}

Delete_Operation::Delete_Operation(char* dn,int auth_type,char *passWord,char **optiuni,int nr_opt,vector<Atribut<char *>> atr)
	:LDAP_Operation(dn,auth_type,optiuni,nr_opt,atr)
{
	result=new char[1000];
	strcpy(result,"ldapmodify ");

	LDAPpassWord = new char[strlen(passWord)+1];
	strcpy(LDAPpassWord,passWord);

}


Delete_Operation::~Delete_Operation(void)
{
}


LDAP_Operation* Delete_Operation::operate()
{
	switch(this->auth_type)
	{
	case 0: strcat(result,"-x ");
		break;
	case 1: strcat(result," ");
		break;
	default: printf("\nExceptie:");
		//exceptie;
	}

	for(int i=0;i<nr_opt;i++)
	{
		strcat(result,option[i]);
		strcat(result," ");
	}

	strcat(result,DN);

	strcat(result," -w ");
	strcat(result,LDAPpassWord);
	strcat(result," -f ");

	
	_LDIF ldif_modify(atribute);
	char ldif[100];
	strcpy(ldif,ldif_modify.Da_LDIF());
	strcat(result,ldif);

	this->ldif_file = new char[strlen(ldif)+1];
	strcpy(ldif_file,ldif);

	printf("The operation:%s",result);

	LDAP_Operation *op=new Delete_Operation((*this));
	//!!!!!!!! SMART POINTERI PT A LUCRA CU CEEA CE RETURNEZI
	return op;
}